
package com.hu.bgp.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.hu.bgp.client.rpc.BgpAdminService;
import com.hu.bgp.shared.*;
import com.hu.bgp.shared.data.ClientGameType;
import com.hu.bgp.shared.data.ClientGameTypeCollection;

public class BgpAdminServiceImpl extends RemoteServiceServlet implements BgpAdminService
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3119967008052554301L;

	public ClientGameTypeCollection getClientGameTypeCollection() {
		// TODO Auto-generated method stub
		System.out.println("BoardGameServiceImpl.getClientGameTypeCollection");
		GameServerContext gsc = GameServerContext.getInstance(getServletContext());

		ClientGameTypeCollection result = new ClientGameTypeCollection();
		for (GameType gt : gsc.getGameTypeCollection())
		{
			//if (!gt.isActive())
				result.add(new ClientGameType(gt.getAlias(), gt.getDisplayName(), gt.getDescription(),gt.isActive()));
		}

		return result;
	}
	
	public void activateGame(ClientGameType gameType){
		GameServerContext gsc = GameServerContext.getInstance(this
				.getServletContext());
		GameType gt = gsc.getGameTypeCollection().getByAlias(
				gameType.getAlias());
		if (!gt.isActive())
			gt.activate();
	}

}
